-
Notifications
You must be signed in to change notification settings - Fork 3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Override PIP_USER if running_under_virtualenv #6984
Conversation
Hello! From the latest comment by @pradyunsg on #5702 (comment) it looks like the intent is to make this an error. |
I don't know if there is more to it, but from reading the other issues it appears it going to be made an error because As far as I can tell this change works around the incompatibility of having a |
There's a couple, based on reading #5702:
We want to provide the ability to have the desired behavior (use virtualenv if in virtualenv, use user if not), but the UI/UX around it is important otherwise we end up with issues and user confusion/frustration. |
Adding As for In any event, this change makes behaviour incrementally less unexpected than the current state.
I'd say this is already the case, and has been since at least 2014. 😉 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We would also need tests for this, but I'm not sure it's worth doing until other people weigh in and can confirm this is a good approach that we want to take while working towards that other issue.
I can understand the rationale. I'm just also aware that this has been "open" since 2014 and it doesn't appear that any progress has been made, and that sometimes "something is better than nothing". Another approach is over here: #7002
Is there any way of poking other people who could weigh in? Even if this particular PR is no good it might trigger some ideas. |
I am not sure whether we want to go down this route, but the way this is implemented currently is definitely not how we'd want to implement this. I'd rather we amend the current check for aborting: diff --git a/src/pip/_internal/commands/install.py b/src/pip/_internal/commands/install.py
index 66071f6e..bb97dbbb 100644
--- a/src/pip/_internal/commands/install.py
+++ b/src/pip/_internal/commands/install.py
@@ -298,10 +298,11 @@ class InstallCommand(RequirementCommand):
"different installation locations"
)
if virtualenv_no_global():
- raise InstallationError(
- "Can not perform a '--user' install. User site-packages "
- "are not visible in this virtualenv."
+ logger.info(
+ "Ignoring '--user', since user site-packages are not "
+ "visible in this virtualenv."
)
+ options.use_user_site = False
install_options.append('--user')
install_options.append('--prefix=') |
I've filed #7164 for discussion on this functionality. |
Hello! I am an automated bot and I have noticed that this pull request is not currently able to be merged. If you are able to either merge the |
Closing since #7002 has merged. |
This PR sets an environment variable to override any
PIP_USER
setting when being used within a virtual environment which sets aVIRTUAL_ENV
environment variable.This works around issues such as #2081, #4141 and #5702 .
It's a pretty naive solution, and I've tested only under Linux so this may be an incomplete solution for macOS/Windows.